import com.zuxia.StartOrder9006;
import com.zuxia.utils.TimeUtils;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;

@SpringBootTest
@ContextConfiguration(classes = StartOrder9006.class)
public class Message {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @Test
    public void mesage() {
        rabbitTemplate.convertAndSend("delay_group", "group","h", new MessagePostProcessor() {
            @Override
            public org.springframework.amqp.core.Message postProcessMessage(org.springframework.amqp.core.Message message) throws AmqpException {
                message.getMessageProperties().setExpiration("10000");
                return message;
            }
        });
        //delay_ex
    }

    @Test
    public void mesage1() {

        rabbitTemplate.convertAndSend("dead_queue_group", "group", "h", new MessagePostProcessor() {
            @Override
            public org.springframework.amqp.core.Message postProcessMessage(org.springframework.amqp.core.Message message) throws AmqpException {
                message.getMessageProperties().setExpiration("10000");
                return message;
            }
        });
        System.out.println(TimeUtils.getY_M_D_H_M_S(System.currentTimeMillis()));
    }

    //delay_ex
    //dead_queue
    @Test
    void test(){
        rabbitTemplate.convertAndSend("delay_ex_group", "group", "TY-1859763425547276288", new MessagePostProcessor() {
            @Override
            public org.springframework.amqp.core.Message postProcessMessage(org.springframework.amqp.core.Message message) throws AmqpException {
                message.getMessageProperties().setExpiration("10000");
                return message;
            }
        });
        System.out.println(TimeUtils.getY_M_D_H_M_S(System.currentTimeMillis()));
    }
}
